package com.ellfors.common.http.utils

import com.ellfors.common.http.entity.BaseException

/**
 * 协程响应类
 */
class CoroutinesConverter<T>(private val options: CoroutinesOptions<T>) {

    fun success(block: suspend (T?) -> Unit): CoroutinesConverter<T> {
        options.success = block
        return this
    }

    fun error(block: suspend (BaseException) -> Unit): CoroutinesConverter<T> {
        options.error = block
        return this
    }

    fun start(block: suspend () -> Unit): CoroutinesConverter<T> {
        options.start = block
        return this
    }

    fun complete(block: suspend () -> Unit): CoroutinesConverter<T> {
        options.complete = block
        return this
    }
}